#include "StaticMesh.h"

#include "Runtime/Rendering/RenderingPrefix.h"

namespace Alice
{
    void StaticMesh::Build()
    {
        StaticMeshBuildVertex staticMeshBuildVertices[3];
        staticMeshBuildVertices[0].mPosition.Set(-0.5f,-0.5f,0.5f);
        staticMeshBuildVertices[1].mPosition.Set(0.5f,-0.5f,0.5f);
        staticMeshBuildVertices[2].mPosition.Set(0.0f,0.5f,0.5f);
        mStaticMeshResource=new StaticMeshResource;
        mStaticMeshResource->mStaticMeshLODResource=new StaticMeshLODResource;
        mStaticMeshResource->mStaticMeshLODVertexFactories=new StaticMeshVertexFactories;
        mStaticMeshResource->mStaticMeshLODResource->mMeshVertexBuffers=new MeshVertexBuffers;
        mStaticMeshResource->mStaticMeshLODResource->mMeshVertexBuffers->mPositionBuffer=new PositionBuffer;
        mStaticMeshResource->mStaticMeshLODResource->mMeshVertexBuffers->mPositionBuffer->mVertexCount=3;
        mStaticMeshResource->mStaticMeshLODResource->mMeshVertexBuffers->mPositionBuffer->mVertexData=new Vector3f[3];
        for(int i=0;i<3;i++)
        {
            mStaticMeshResource->mStaticMeshLODResource->mMeshVertexBuffers->mPositionBuffer->mVertexData[i]=staticMeshBuildVertices[i].mPosition;
        }
        //mStaticMeshResource->mStaticMeshLODResource->InitResources(this,0);
        mStaticMeshResource->mStaticMeshLODResource->mSections.resize(1);
        mStaticMeshResource->mStaticMeshLODResource->mSections[0].MaterialIndex=0;
        mStaticMeshResource->InitResources(this);
        Debug("Build Static Mesh");
    }
}
